<?php

namespace app\admin\controller;

use app\admin\model\Paper;
use app\BaseController;

class Count extends BaseController
{
    /* 统计 */
    public function index()
    {
        if (!$this->request->auth) return show(config('status.auth'), 'Authorization Failed');
        $isReadCount  = Paper::where('is_pay', 1)->where('is_read', 1)->count();
        $noReadCount  = Paper::where('is_pay', 1)->where('is_read', 0)->count();
        $totalPrice   = Paper::where('is_pay', 1)->sum('price');
        $todayPrice   = Paper::where('is_pay', 1)->whereDay('pay_time')->sum('price');
        return show(config('status.success'),   "success", compact('isReadCount', 'noReadCount', 'totalPrice', 'todayPrice'));
    }
}
